Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for data structures #37

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tobias-kuendig
Copy link

@tobias-kuendig tobias-kuendig commented May 27, 2016

This feature lets you reduce redundant definitions in your doc blocks by the use of data structures:

/**
 * Elements Collection
 *
 * @Resource("Elements", uri="/elements")
 *
 * @DataStructures({
 *     @Type("Element", type="object", properties={
 *          @Property("id", type="number", description="Internal identifier", sample=1),
 *          @Property("name", type="string", description="Element name", sample="element")
 *     }),
 *     @Type("Pagination", type="object", properties={
 *          @Property("total", type="number", description="Total items", sample=9),
 *          @Property("per_page", type="number", description="Items per page", sample=3)
 *     }),
 *     @Type("Meta", type="object", properties={
 *          @Property("pagination", type=@Type("Pagination"), description="Pagination information")
 *     })
 * })
 */
class ElementController extends BaseController {

    /**
     * Show all elements
     *
     * Get a JSON representation of all the elements
     *
     * @Get("/")
     * @Response(200, attributes={
     *     @Attribute("success", type="boolean", sample="true", required=true, description="Status of the request"),
     *     @Attribute("data", type={@Type("Element")}, description="Element data", required=true),
     *     @Attribute("meta", type=@Type("Meta"), description="Meta information", required=true)
     * })
     */
    public function index()
    {
        // This definition results in the following response:
        //
        // {
        //  "success": true,
        //  "data": [
        //    {
        //      "id": 1,
        //      "name": "element"
        //    }
        //  ],
        //  "meta": {
        //      "pagination": {
        //          "total": 9,
        //          "per_page": 3
        //      }
        //  }
        //}
    }

    /**
     * Show specific element
     *
     * Get a JSON representation of a specific element
     *
     * @Get("/{element_id}")
     *
     * @Response(200, attributes={
     *     @Attribute("success", type="boolean", sample="true", required=true, description="Status of the request"),
     *     @Attribute("data", type=@Type("Element"), description="Element data", required=true)
     * })
     * @Parameters({
     *      @Parameter("element_id", type="integer", required=true, description="The element's id", example=1)
     * })
     */
    public function show()
    {
        // This definition results in the following response:
        //
        // {
        //  "success": true,
        //  "data": {
        //    "id": 1,
        //    "name": "element"
        //  }
        //}
    }
}

Tobias Kündig added 2 commits May 27, 2016 11:30
Moved data structures to the end so resource groups don't get split up

Consolidate all data structures into one section

Restructured

Applied style ci patch

Fixed tests
@mirzap
Copy link

mirzap commented Jul 29, 2016

I would really like to see this in the official package 👍

mikeburke-adz added a commit to mikeburke-adz/blueprint that referenced this pull request May 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants